<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('疫情防控信息填报')" />

    <link
            rel="stylesheet"
            href="https://res.wx.qq.com/open/libs/weui/1.1.3/weui.min.css"
    />

    <style type="text/css">
        body {
            font-size: 15px;
        }
        .form-horizontal .form-group {
            margin-top: 20px;
        }
        .alert {
            padding: 8px;
            margin-bottom: 10px;
            border: 1px solid transparent;
            border-radius: 4px;
        }
        .weui-cell {
            padding: 5px 10px;
        }
        .weui-cell:before {
            border-top: 20px solid var(--weui-FG-3);
        }
    </style>
</head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<body class="white-bg" style="background-color: #e9ecef;">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
            <form class="form-horizontal m" id="form-collect-add">
                <input name="userId" class="form-control" type="hidden" th:value="${userId}">
                <input name="deptId" class="form-control" type="hidden">
                <div class="weui-cells">
                    <label for="name" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">姓名<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                            <input id="name" name="name" class="weui-input" th:value="${name}" placeholder="填写本人姓名"/>
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <label for="deptName" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">部门<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                            <input id="deptName" name="deptName" class="weui-input" th:value="${deptName}" placeholder="填写本人所属部门"/>
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <label for="position" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">岗位<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                            <input id="position" name="position" class="weui-input" th:value="${position}" placeholder="填写本人所属部门"/>
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <label for="area" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">目的地<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                        <input id="area" name="area" class="weui-input" placeholder="填写目的地"/>
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <label for="phonenumber" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">手机号码<i class="text-danger">*</i></span></div>
                            <div class="weui-cell__bd">
                            <input id="phonenumber" name="phonenumber" class="weui-input">
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <label for="reason" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">外出事由<i class="text-danger">*</i></span></div>
                            <div class="weui-cell weui-cell_active">
                                <div class="weui-cell__bd">
                                    <textarea id="reason" class="weui-textarea" placeholder="请描述外出事由" rows="3"></textarea>
                                    <div role="option" aria-live="polite" class="weui-textarea-counter"><span>0</span>/200</div>
                                </div>
                            </div>
                    </label>
                </div>


                <div class="weui-cells">
                    <label for="startTime" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">开始时间<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                            <input type="text" name="startTime" class="weui-input" placeholder="yyyy-MM-dd" id="startTime" required="required">
                        </div>
                    </label>
                    <label for="endTime" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">结束时间<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                            <input type="text" name="endTime" class="weui-input" placeholder="yyyy-MM-dd" id="endTime" required="required">
                        </div>
                    </label>
                    <label for="outsideTime" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">外出时间<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                            <input id="outsideTime" name="outsideTime" class="weui-input" placeholder="天"/>
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <label for="traffic" class="weui-cell weui-cell_active">
                        <div class="weui-cell__hd"><span class="weui-label">交通工具<i class="text-danger">*</i></span></div>
                        <div class="weui-cell__bd">
                        <textarea name="traffic" id="traffic" class="weui-input" ></textarea>
                        </div>
                    </label>
                </div>

                <div class="weui-cells">
                    <h>个人声明：1.以上填报信息真实准确。
                        2.单位已向我宣传，非必要不出省、不离肥，不参加规模性聚会、聚餐及聚集性活动，加强个人防护，并告知外出疫情防控有关注意事项。
                        3.外出期间我将严格按照国家、省市、公司疫情防控要求，切实做好应对疫情的个人防控。
                        4.按时返肥并主动销号；返肥后如有不适及时就医并上报。
                        5.如近14天内旅居、途径地升级为中高风险地区或疾控部门通知本人及家属涉疫情形的，我将第一时间向所在居委（村委）、单位报备，立即落实核酸检测。
                        6.如出省返肥的，主动核酸检测，并自我观察14天，有情立即报告。</h>
                </div>

                <div class="weui-cells">
                    <div class="weui-cell weui-cell_active weui-cell_select weui-cell_select-after">
                        <div class="weui-cell__hd">
                            <label for="promise" class="weui-label">本人承诺<i class="text-danger">*</i></label>
                        </div>
                        <div class="weui-cell__bd">
                            <select class="weui-select" name="promise" id="promise" placeholder="请选择">
                                <option value="1">我承诺</option>
                            </select>
                        </div>
                    </div>
                </div>

            </form>



</div>
<div class="row">
    <div class="col-sm-12" style="text-align: center">
        <button type="button" class="btn btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
        <br>
        <br><br>
    </div>
</div>
<th:block th:include="include :: footer" />


<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script>


    var now = new Date();
    var year = now.getFullYear(); //年
    var month = now.getMonth() + 1; //月
    var day = now.getDate(); //日
    var hour = now.getHours(); //小时
    var order_time = `${year}-${month}-${day} ${hour}:00:00`;

    // 日期选择控件
    var yearList = [String(year-1),String(year)];
    var monthList = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
    var dayList = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
        "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31"
    ];

    var dataList = [];
    var index = 0;
    for (var i = 0; i < yearList.length; i++) {
        // if (year <= +yearList[i]) {
        var a = {};
        a.value = yearList[i];
        a.label = `${yearList[i]}年`;
        index++;
        a.children = [];
        for (var j = 0; j < monthList.length; j++) {
            var b = {};
            b.label = `${monthList[j]}月`;
            b.value = monthList[j];
            index++;
            if (year == +yearList[i]) {
                //if (month - 1 <= j) {
                a.children[a.children.length] = b;
                //}
            } else {
                a.children[a.children.length] = b;
            }
            b.children = [];
            for (var o = 0; o < dayList.length; o++) {
                var c = {};
                c.label = `${dayList[o]}日`;
                c.value = dayList[o];
                index++;
                if (month == +monthList[j]) {
                    //if (day - 1 <= o) {
                    b.children[b.children.length] = c;
                    // }
                } else {
                    b.children[b.children.length] = c;
                }
                c.children = [];

                if (j + 1 == 4 || j + 1 == 6 || j + 1 == 0 || j + 1 == 11) {
                    if (o == 29) o = 31;
                } else if (j + 1 == 2) {
                    if (
                        (+yearList[i] % 4 == 0 && +yearList[i] % 100 != 0) ||
                        +yearList[i] % 400 == 0
                    ) {
                        if (o == 28) o = 31;
                    } else {
                        if (o == 27) o = 31;
                    }
                }
            }
        }
        dataList[dataList.length] = a;
        // }
    }
    var appointment = '';

    $("#startTime").click(function () {
        weui.picker(dataList, {
            className: "custom-classname",
            container: "body",
            defaultValue: [year, month, day, hour],
            onChange: function (result) {},
            onConfirm: function (result) {
                appointment = result[0] + "-" + result[1] + "-" + result[2] ;
                $("#startTime").val(appointment)
                order_time = `${result[0]}-${result[1]}-${result[2]}`
            },
            id: "startTime"
        });
    });
    $("#endTime").click(function () {
        weui.picker(dataList, {
            className: "custom-classname",
            container: "body",
            defaultValue: [year, month, day, hour],
            onChange: function (result) {},
            onConfirm: function (result) {
                appointment = result[0] + "-" + result[1] + "-" + result[2] ;
                $("#endTime").val(appointment)
                order_time = `${result[0]}-${result[1]}-${result[2]}`
            },
            id: "endTime"
        });
    });
    $("#outsideTime").click(function () {
        weui.picker(dataList, {
            className: "custom-classname",
            container: "body",
            defaultValue: [year, month, day, hour],
            onChange: function (result) {},
            onConfirm: function (result) {
                appointment = result[0] + "-" + result[1] + "-" + result[2] ;
                $("#outsideTime").val(appointment)
                order_time = `${result[0]}-${result[1]}-${result[2]}`
            },
            id: "outsideTime"
        });
    });
</script>
<script th:inline="javascript">
    var prefix = ctx + "wxcp/epidemic/collect"
    $("#form-collect-add").validate({
        focusCleanup: true
    });

    var up_flag3 = 0;
    var up_flag4 = 0;
    var up_flag5 = 0;

    function submitHandler() {
        if ($.validate.form()) {
            $.modal.confirmAduit("是否确认提交您的填报内容?", function() {
                // $.operate.save(prefix + "/add", $('#form-collect-add').serialize());
                var akm = $("#akmPath").val();
                var xcm = $("#xcmPath").val();
                var config = {
                    url: prefix + "/add",
                    type: "post",
                    dataType: "json",
                    data: $('#form-collect-add').serialize(),
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍候...");
                        $.modal.disable();
                    },
                    success: function(result) {
                        if (typeof callback == "function") {
                            callback(result);
                        }
                        callback(result);
                    }
                };
                $.ajax(config)
            });
        }
    }

    function callback(result){
        if (result.code == web_status.SUCCESS) {
            // 跳转到保存成功页面
            window.location.href = ctx + "common/success";
        } else if (result.code == web_status.WARNING) {
            $.modal.enable();
            $.modal.closeLoading();
            $.modal.confirm("你已经提交了疫情防控收集表，请不要重复提交！", function() {
                $.modal.enable();
                $.modal.closeLoading();
                window.location.href = ctx + "wxcp/epidemic/collect/show/"+result.msg;
            });
        }  else {
            $.modal.alertError(result.msg);
        }
    }


    document.getElementById("startTime").onclick = function() {
        document.activeElement.blur();
    };

    document.getElementById("endTime").onclick = function() {
        document.activeElement.blur();
    };

    document.getElementById("outsideTime").onclick = function() {
        document.activeElement.blur();
    };


</script>
</body>
</html>
